﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;

namespace BLL
{
  public class ProductInColourBLL
  {
    public List<ProductInColour> GetByColourId(int colourId)
    {
      using (var data = new DigitalColorCMSDataContext(_Global.StringConnect))
      {
        return data.ProductInColours.Where(p => p.IdColour == colourId).ToList();
      }
    }
    public List<ProductInColour> GetByProductId(string productId)
    {
      using (var data = new DigitalColorCMSDataContext(_Global.StringConnect))
      {
        return data.ProductInColours.Where(p => p.IdProduct == productId).ToList();
      }
    }
    public void Add(ProductInColour obj)
    {
      using (var data = new DigitalColorCMSDataContext(_Global.StringConnect))
      {
        data.ProductInColours.InsertOnSubmit(obj);
        data.SubmitChanges();
      }
    }
    public void DeleteBySizeId(int sizeId)
    {
      using (var data = new DigitalColorCMSDataContext(_Global.StringConnect))
      {
        List<ProductInColour> list = data.ProductInColours.Where(p => p.IdColour == sizeId).ToList();
        data.ProductInColours.DeleteAllOnSubmit(list);
        data.SubmitChanges();
      }
    }
    public void DeleteByProductId(string productId)
    {
      using (var data = new DigitalColorCMSDataContext(_Global.StringConnect))
      {
        List<ProductInColour> list = data.ProductInColours.Where(p => p.IdProduct == productId).ToList();
        data.ProductInColours.DeleteAllOnSubmit(list);
        data.SubmitChanges();
      }
    }
  }
}
